package com.qf.util;

public class R<T> {
    private Integer code;
    private String msg;
    private T data;

    //进一步封装R 因为不想在controller或者 service 去new R
    public static <T> R<T> ok(T data) {
        return new R<>(2000, "成功", data);
    }
    public static <T> R<T> ok(String msg, T data) {
        return new R<>(2000, msg, data);
    }
    public static <T> R<T> ok(Integer code, String msg, T data) {
        return new R<>(code, msg, data);
    }
    public static <T> R<T> fail(Integer code, String msg, T data) {
        return new R<>(code, msg, data);
    }
    public static <T> R<T> fail(T data) {
        return new R<>(5000, "成功", data);
    }
    public static <T> R<T> fall(String msg, T data) {
        return new R<>(5000, msg, data);
    }
    public R() {
    }

    public R(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
